package affd.logic;

import java.util.ArrayList;

/**
 * A Sentence is a collection of tokens which constructs a single sentence.
 * 
 * @author Joteitti joteitti@cc.hut.fi
 *
 */
public class Sentence {

	protected ArrayList<Token> tokens;
	
	/**
	 * Constructs a empty sentence.
	 */
	public Sentence() {
		tokens = new ArrayList<Token>();		
	}
	
	/**
	 * Inserts the specified token to the list.
	 * 
	 * @param token Token to be added.
	 */
	public void addToken(Token token) {
		tokens.add(token);
		
		// Set parent
		token.setParent(this);
	}
	
	/**
	 * Returns the list of the tokens.
	 * 
	 * @return List of tokens.
	 */
	public ArrayList<Token> getTokens()
	{
		return tokens;
	}
	
	/**
	 * Returns a string representation of this sentence.
	 */
	public String toString() {
		StringBuffer sentence = new StringBuffer();
		for(Token token : tokens) {
			sentence.append(token.getContent());
		}
		
		return sentence.toString();
	}

}
